import { status, statusList } from '@/utils/enums'
const groupsOptions = [
  { label: '技术部', value: 'jishu' },
  { label: '销售部', value: 'xiaoshou' }
]

/** 表单 */
export const formData = {
  name: '',
  phone: '',
  group: '',
  daterange: ''
}
export const formConfig = [
  {
    type: 'input',
    prop: 'name',
    label: '姓名',
    clearable: true
  },
  {
    type: 'input',
    prop: 'phone',
    label: '手机号码',
    clearable: true,
    formatter: (value) => value.replace(/[^\d]/g, '')
  },
  {
    type: 'select',
    prop: 'group',
    label: '部门',
    clearable: true,
    options: groupsOptions
  },
  {
    type: 'select',
    prop: 'select',
    label: '用户状态',
    clearable: true,
    isEnum: true,
    options: status
  }
]
/** 表格 */
export const tableColumns = [
  {
    label: '姓名',
    prop: 'name'
  },
  {
    label: '手机号码',
    prop: 'phone'
  },
  {
    label: '部门',
    prop: 'group'
  },
  {
    label: '状态',
    prop: 'status',
    filter: (val) => status[val]
  },
  {
    label: '入职时间',
    prop: 'entryTime'
  },
  {
    label: '操作',
    prop: 'operation',
    slotName: 'operation'
  }
]

/** 新增 编辑 */
export const aFormData = {
  name: '',
  phone: '',
  sex: 1,
  group: '',
  username: '',
  password: '',
  status: 1
}
export const aFormConfig = [
  {
    type: 'input',
    prop: 'name',
    label: '姓名',
    span: 24,
    clearable: true
  },
  {
    type: 'input',
    prop: 'phone',
    label: '手机号',
    span: 24,
    clearable: true,
    formatter: (value) => value.replace(/[^\d]/g, '')
  },
  {
    type: 'radio',
    prop: 'sex',
    label: '性别',
    span: 24,
    options: [
      { name: '男', value: 1 },
      { name: '女', value: 2 }
    ]
  },
  {
    type: 'select',
    prop: 'group',
    label: '部门',
    span: 24,
    clearable: true,
    options: groupsOptions
  },
  {
    type: 'input',
    prop: 'username',
    label: '用户名',
    span: 24,
    clearable: true
  },
  {
    type: 'input',
    prop: 'password',
    label: '密码',
    span: 24,
    showPassword: true,
    clearable: true
  },
  {
    type: 'radio',
    prop: 'status',
    label: '用户状态',
    span: 24,
    options: statusList
  }
]
export const aFormRules = {
  name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
  group: [{ required: true, message: '请选择部门', trigger: 'change' }],
  username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  password: [{ required: true, message: '请输入密码', trigger: 'change' }]
}
